// DesignExtractor.h : DesignExtractor is used to store all the data into the tables.
// Author: Achyut P Balaji
//
#ifndef DESIGN_EXTRACTOR_H
#define DESIGN_EXTRACTOR_H

#include<iostream>
#include<string>
#include<vector>
#include"VarTable.h"
#include"ModifyVarTable.h"
#include"ModifyStatTable.h"
#include"ModifyProcTable.h"
#include"ProcTable.h"
#include"SPA_Data_Types.h"
#include"CallsTable.h"
#include"StatTable.h"
#include"UsesStatTable.h"
#include"UsesVarTable.h"
#include"UsesProcTable.h"
#include"AST_Query.h"

using namespace std;

enum BLOCK_TYPE {BLOCK_WHILE,BLOCK_IF};

class DesignExtractor {
private:
	AST_Query *astquery;
	VarTable* varTable;
	ProcTable* procTable;
	StatTable* statTable;
	ModifyVarTable* modifyVar;
	ModifyStatTable* modifyStat;
	ModifyProcTable* modifyProc;
	UsesVarTable* usesVar;
	UsesStatTable* usesStat;
	UsesProcTable* usesProc;
	CallsTable* callsTable;
	string str;
	vector<VAR_INDEX> RHS_LIST;
public:

	DesignExtractor(AST *a) {
		this->astquery = new AST_Query(a);
		varTable = VarTable::getInstance();
		procTable = ProcTable::getInstance();
		statTable = StatTable::getInstance();
		modifyVar = ModifyVarTable::getInstance();
		modifyStat = ModifyStatTable::getInstance();
		modifyProc = ModifyProcTable::getInstance();
		usesVar = UsesVarTable::getInstance();
		usesStat = UsesStatTable::getInstance();
		usesProc = UsesProcTable::getInstance();
		callsTable = CallsTable::getInstance();
		modifyVar->initialise(varTable->getTotalSize());
		usesVar->initialise(varTable->getTotalSize());
		callsTable->initialise(procTable->getSize());
	};


	BOOLEAN fillTable();
	void parseExpr(stack<STRING> *s, expr *e);
	//void getModifyUsesList(STATEMENT_INDEX blockNo,vector<VAR_INDEX> &usedVar, vector<VAR_INDEX> &modifiedVar);
	void getModifyUsesList(STATEMENT_INDEX blockNo, vector<VAR_INDEX> &usedVar, vector<VAR_INDEX> &modifiedVar,BLOCK_TYPE type);
	void insertCallsData(vector<PROC_INDEX> callStmt);
	void getNextStmts(STMT_VCTR &stmtVector);

};

#endif